//
//  ILGProxy.m
//  ILGDemo
//
//  Created by happy on 2020/5/6.
//  Copyright © 2020 Happy. All rights reserved.
//

#import "ILGProxy.h"

@implementation ILGProxy

- (instancetype)initWithTarget:(id)target{
    _target = target;
    return self; //奇怪吧！因为没有默认的init实现
}

+ (instancetype)proxyWithTarget:(id)target{
    return [[self alloc] initWithTarget:target];
}

- (void)dealloc {
//    NSLog(@"%s", __func__);
}


- (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector {
    return [self.target methodSignatureForSelector:aSelector];
}

- (void)forwardInvocation:(NSInvocation *)invocation{
    SEL sel = [invocation selector];
    if ([self.target respondsToSelector:sel]) {
        [invocation invokeWithTarget:self.target];
    } else {
        [super forwardInvocation:invocation];
    }
}

@end
